<!DOCTYPE html>
<html lang="en">

<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>获取URL参数</title>
</head>

<body>
  <script>
    function getUrlObj(url) {
      //获取['a=1', 'b=2', 'c=', 'd=shmhm']
      var params = url.split('?')[1].split('&')
      console.log(params)
      var obj = {}
      //转对象把=前面的去除
      params.map((item) => (
        obj[item.split('=')[0]] = item.split('=')[1]
      ))
      return obj
    }
    console.log(getUrlObj('http://item.taobao.com/item.htm?a=1&b=2&c=&d=shmhm'))



  </script>
</body>

</html>